home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / amos / amcafext.lha / AMCAF_Examples / SetRainColour1.AMOS / SetRainColour1.amosSourceCode < prev    next >
AMOS Source Code  |  1995-07-14  |  2KB  |  81 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Set Rain Colour  
  3. ' *           Amcaf Examples          * Glue Colour
  4. ' *      Set Rain Colour 1 V1.1       *  
  5. ' *      Written by Chris Hodges      *  
  6. ' *                                   *  
  7. ' *************************************  
  8. '    
  9. ' We need enough buffer for a 256 pixel high sprite. 
  10. Set Sprite Buffer 262
  11. ' Hide the mouse, we need every sprite!                        
  12. Hide On 
  13. ' Open a two colours screen. 
  14. Screen Open 0,320,256,2,Lowres
  15. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  16. ' Copy the sprite palette into the colour registers 16-31. 
  17. Get Sprite Palette 
  18. For A=0 To 15 : Colour A+16, Colour(A) : Next 
  19. ' Print some boring text :)
  20. Locate 0,16 : Centre "Set Rain Colour for sprite colours!"
  21. ' Setup a rainbow. Note that you can't set a rainbow to colours higher 
  22. ' than 15. 
  23. Set Rainbow 0,0,1024,"","",""
  24. ' Now Set Rain Colour comes into action. We can assign the rainbow to any  
  25. ' other colour.
  26.  Extension_8_1330 0,31
  27. ' Fill the rainbow with some nice colour values. 
  28. ' C0 is used for the red part of the colour, C1 for the green and C2 for 
  29. ' the blue part. Then the three values are joined using Glue Colour. 
  30. ' D0,D1 and D2 are used to hold the addition value.
  31. C0=0 : C1=48 : C2=0
  32. S0=Rnd(3)+1 : S1=Rnd(3)+1 : S2=Rnd(3)+1
  33. For A=0 To 1023
  34.   ' Smoothly change the colour values. 
  35.   Add C0,S0 : Add C1,S1 : Add C2,S2
  36.   ' Check if colour is going to be 'outside'.
  37.   If C0<0 Then C0=0 : S0=Rnd(3)+1
  38.   If C0>127 Then C0=127 : S0=-Rnd(3)-1
  39.   If C1<0 Then C1=0 : S1=Rnd(3)+1
  40.   If C1>127 Then C1=127 : S1=-Rnd(3)-1
  41.   If C2<0 Then C2=0 : S2=Rnd(3)+1
  42.   If C2>127 Then C2=127 : S2=-Rnd(3)-1
  43.   Rain(0,A)= Extension_8_0A0E(C0/8,C1/8,C2/8)
  44. Next 
  45. RY=0
  46. X=-64*16 : SX=100 : D=0
  47. Repeat 
  48.   Wait Vbl 
  49.   ' Display the rainbow. 
  50.   Rainbow 0,RY,Y Hard(-1),258
  51.   ' RY holds the base of the rainbow, and this value is increased all the time 
  52.   ' to scroll the rainbow up.
  53.   Add RY,1,0 To 1023
  54.   ' Display the sprite.
  55.   Sprite 0,X Hard(X/16),Y Hard(0),1
  56.   ' Add the speed to the position. 
  57.   Add X,SX
  58.   ' Accelerate and bounch. 
  59.   If D=0
  60.     Dec SX
  61.     If X<0 and SX<0
  62.       If SX<-10
  63.         SX=-SX/2 : X=0
  64.       Else 
  65.         D=1 : SX=16 : X=0
  66.       End If 
  67.     End If 
  68.   Else 
  69.     Inc SX
  70.     If X>256*16-1 and SX>0
  71.       If SX>10
  72.         SX=-SX/2 : X=256*16-1
  73.       Else 
  74.         D=0 : SX=-16
  75.       End If 
  76.     End If 
  77.   End If 
  78. Until Inkey$=Chr$(27) or Mouse Key<>0
  79. Sprite Off 
  80. Screen Close 0
  81. End